package com.gcosc.hly.codejava.exception;

import com.gcosc.hly.codejava.Utils.MailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ExceptionMail {

    @Autowired
    private MailUtils mailUtils;

    @Value("${sysRoot.roots}")
    private String roots;

    @Value("${sysRoot.isMail}")
    private boolean isMail;

    public void sendMails(String title,String message){
        if (isMail){
            String[] split = roots.split(";");
            for (String r : split){
                mailUtils.sendTextMailMessage(r,title,message);
            }
        }
    }

}
